<?php
    drupal_add_js("js/jquery.validate.min.js");
    drupal_add_js("js/product.form.js");
    drupal_add_css("css/product.css");
?>
<form method="POST" action="<?php print url('backend/submit') ?>" enctype="multipart/form-data" id="product_form">
    <table class="tab_add_product">
        <tr>
            <td align="right"><span class="field_require">*</span>Tên sảng phẩm: </td>
            <td>
                <input type="text" name="pro_name" id="pro_name" value="<?php echo $data['edit'][0]['product_name'] ?>" style="float: left" />
                <div id="error" style="float: left"><ul></ul></div>
            </td>
        </tr>
        <tr>
            <td align="right">Giá sản phẩm: </td>
            <td>
                <input type="text" name="pro_price" id="pro_price" value="<?php echo $data['edit'][0]['product_price']?>" />
            </td>
        </tr>
         <tr>
            <td align="right">Loại sản phẩm: </td>
            <td>
                <select name="pro_type" id="pro_type">
                    <option value="">--Chọn Loại sản phẩm--</option>
                    <option value="1" <?php if($data['edit'][0]['product_type']==1) echo "selected='selected'"?>>Cũ</option>
                    <option value="2" <?php if($data['edit'][0]['product_type']==2) echo "selected='selected'"?>>Mới</option>
                </select>
            </td>
            
        </tr>
         <tr>
            <td align="right">Xuất xứ : </td>
            <td>
                <select name="pro_origin" id="pro_origin">
                    <option value="">--Chọn Loại sản phẩm--</option>
                    <option value="1" <?php if($data['edit'][0]['product_origin']==1) echo "selected='selected'"?>>Xách tay</option>
                    <option value="2" <?php if($data['edit'][0]['product_origin']==2) echo "selected='selected'"?>>Chính hãng</option>
                    <option value="3" <?php if($data['edit'][0]['product_origin']==3) echo "selected='selected'"?>>Công ty</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right">Bảo hành: </td>
            <td>
                <input type="text" name="pro_warranty" id="pro_warranty" value="<?php echo $data['edit'][0]['product_warranty']?>" />
            </td>
        </tr>
        <tr>
            <td align="right">Khuyến mãi: </td>
            <td>
                <textarea style="width: 200px;height:100px" name="pro_promote" id="pro_promote"><?php echo $data['edit'][0]['product_promote']?></textarea>
            </td>
        </tr>
        <tr>
            <td align="right">Mô tả sản phẩm: </td>
            <td>
                <textarea style="width: 400px;height:200px" name="pro_description" id="pro_description"><?php echo $data['edit'][0]['product_description']?></textarea>
            </td>
        </tr>
        <tr>
            <td align="right"><span class="field_require">*</span>Thương hiệu sản phẩm: </td>
            <td>
                <?php
                    echo createSelect('brand_id','brand_id',$data['brand'],$data['edit'][0]['product_brand'],'Chọn danh mục',1);
                ?>
            </td>
        </tr>
        <tr>
            <td align="right"><span class="field_require">*</span>Chọn khoảng giá: </td>
            <td>
                <?php
                    echo createSelect('cprice_id','cprice_id',$data['price'], $data['edit'][0]['product_bracket'],'Chọn danh mục',1);
                ?>
            </td>
        </tr>
        <?if($data["edit"]){?>
        <tr>
            <td align="right">Ảnh hiện tại :</td>
            <td><?php echo '<img src="' . base_path() . "files/products/" . $data['edit'][0]['product_image'] . '" width=100px />'?></td>
        </tr>
        <?}?>
        <tr>
            <td align="right">Chọn ảnh đại diện :</td>
            <td><input type="file" name="file" value="file" /></td>
            <input type="hidden" name="checkEdit" value="<?php echo $data['edit'][0]["product_id"]?>" />
            <input type="hidden" name="name_image" value="<?php echo $data['edit'][0]["product_image"]?>" />
            <input type="hidden" name="cate_id" id="cate_id" value ="<?php echo $data["cate_id"]?>" />
        </tr>
        <tr>
            <td align="right"></td>
            <td>
                <input type="submit" value="Thêm mới" />
                <input type="reset" value="Làm lại" />
            </td>
        </tr>
    </table>
</form>
